<?php

/**
 * article actions.
 *
 * @package    theconnexter
 * @subpackage article
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class articleActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    
  }
  private $idr=0;
  public function executeShow(sfWebRequest $request){
	$idrubrique = Doctrine_core::getTable('article')->getIdRubrique($request->getParameter('id'));
	foreach($idrubrique as $id){
		$this->idr=$id->getRubriqueId();
		$this->ida=$id->getId();
	}
	Doctrine_core::getTable('rubrique')->updateRubrique($this->idr);
	$this->form= new CommentaireForm();
	$this->detailsArticle=$this->getRoute()->getObject();
	$this->comment=Doctrine_core::getTable('commentaire')->getCommentByArticle($this->ida ,0);
  }
  
  public function executeComment(sfWebRequest $request){
	$this->form=new commentaireForm();
	if($request->isMethod('post')){
		$param=$request->getParameter($this->form->getName());
		$param['etat'] = 0;
		$param['articleid'] = $request->getParameter('idarticle');
		$request->setParameter($this->form->getName(),$param);
		$this->processForm($request, $this->form);
	}
  }
  protected function processForm(sfWebRequest $request, sfForm $form){
	$form->bind($request->getParameter($form->getName()));
	if ($form->isValid()){
		$form->save();
		$this->redirect('@homepage');
	}
  }
}